import matplotlib.pyplot as plt
import numpy as np


if __name__ == '__main__':
    X = ["1000", "2000", "3000", "4000", "5000", "6000", "7000", "8000", "9000", "10,000"]
    # X = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
    Y1 = [713.84, 711.84, 701.84, 731.4, 720.4, 703.2, 702.84, 701.84, 690.84, 682.14] # 吞吐量
    Y2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100] # 成功率
    # Y3 = ["SR:100%", "SR:1", "SR:1", "SR:1", "SR:1", "SR:1", "SR:1", "SR:1", "SR:1", "SR:1"] #结点上的坐标
    # for i in range(1, len(Y1)):
    #     Y2.append((Y1[i] - Y1[i - 1]) / Y1[i - 1])

    fig, ax1 = plt.subplots()
    # plt.xticks(rotation=45)
    # ax1.set_title('READ Performance')
    ax1.plot(X, Y1, color="blue", label="Throughput", linewidth=1.0, linestyle='-', marker='o')
    # for循环
    # ax1.annotate(text='3', xy=("100", 200))

    ax1.set_xlabel("txNumber", fontsize=15)
    ax1.set_ylabel("Throughput (TPS)", fontsize=15)
    plt.xticks(fontsize=13, rotation=30)
    plt.yticks(np.linspace(100, 1000, 10, endpoint=True), fontsize=13)

    # 在上面这条线上，增加时延

    # 不显示呢？？？https://www.modb.pro/db/412416

    ax2 = ax1.twinx()
    ax2.plot(X, Y2, color="orange", label="Success Rate",linewidth=1.5,linestyle=':',marker='o')
    ax2.set_ylabel("Success Rate (%)", fontsize=15)
    plt.yticks(np.linspace(10, 100, 10, endpoint=True), fontsize=13)

    fig.legend(loc="center left", bbox_to_anchor=(0, 0, 0, 1), bbox_transform=ax1.transAxes, fontsize=15)

    plt.savefig('/Users/minghuili/Downloads/8-b-eps-converted-to.pdf', dpi=300, bbox_inches = 'tight')
    plt.show()